home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F35028_mapTree.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  2.6 KB  |  77 lines

  1. <xsl:stylesheet version="1.0" 
  2.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.  xmlns:saxon="http://icl.com/saxon"
  4.  xmlns:mapTree-cons="mapTree-cons" 
  5.  xmlns:mapTree-makeNode-f="mapTree-makeNode-f" 
  6.  exclude-result-prefixes="xsl saxon mapTree-cons mapTree-makeNode-f"
  7. >
  8.     <xsl:import href="foldl-tree.xsl"/>
  9.  
  10.     <mapTree-cons:mapTree-cons/>
  11.     <mapTree-makeNode-f:mapTree-makeNode-f/>
  12.     
  13.     <xsl:template name="mapTree">
  14.       <xsl:param name="pTree"/>
  15.       <xsl:param name="pFun"/>
  16.       
  17.       <xsl:variable name="vmakeNode" select="document('')/*/mapTree-makeNode-f:*[1]"/>
  18.       <xsl:variable name="vCons" select="document('')/*/mapTree-cons:*[1]"/>
  19.       
  20.       <xsl:variable name="vFuncNode">
  21.         <mapTree-makeNode-f:mapTree-makeNode-f/>
  22.         <xsl:copy-of select="$pFun"/>
  23.       </xsl:variable>
  24.       
  25.       <xsl:call-template name="foldl-tree">
  26.         <xsl:with-param name="pFuncNode" select="saxon:node-set($vFuncNode)/*"/>
  27.         <xsl:with-param name="pFuncSubtrees" select="$vCons"/>
  28.         <xsl:with-param name="pA0" select="/.."/>
  29.         <xsl:with-param name="pNode" select="$pTree"/>
  30.       </xsl:call-template>
  31.     </xsl:template>
  32.  
  33.     <xsl:template match="*[namespace-uri()='mapTree-cons']">
  34.       <xsl:param name="arg1"/>
  35.       <xsl:param name="arg2"/>
  36.       
  37.       <xsl:copy-of select="$arg1"/>
  38.       <xsl:copy-of select="$arg2"/>
  39.     </xsl:template>
  40.     
  41.     <xsl:template match="*[namespace-uri()='mapTree-makeNode-f']">
  42.       <xsl:param name="arg0"/> <!-- must contain pFun -->
  43.       <xsl:param name="arg1"/> <!-- must contain the node -->
  44.       <xsl:param name="arg2"/> <!-- must contan pA0 -->
  45.       
  46.       <xsl:variable name="vFun1Result">
  47.          <xsl:apply-templates select="$arg0[1]">
  48.            <xsl:with-param name="arg1" select="$arg1"/>
  49.          </xsl:apply-templates>
  50.       </xsl:variable>
  51.  
  52.       <xsl:element name="{name($arg1/..)}">
  53.       <xsl:apply-templates select="$arg1" mode="copy">
  54.         <xsl:with-param name="pContents" select="saxon:node-set($vFun1Result)"/>
  55.       </xsl:apply-templates>
  56.       <xsl:copy-of select="$arg1/../node()[not(self::*)]"/>
  57.       <xsl:copy-of select="$arg2"/>
  58.       </xsl:element>
  59.     </xsl:template>
  60.  
  61.     <xsl:template match="node()" mode="copy">
  62.       <xsl:param name="pContents"/>
  63.       
  64.       <xsl:copy>
  65.         <xsl:copy-of select="$pContents"/>
  66.       </xsl:copy>
  67.     </xsl:template>
  68.  
  69.     <xsl:template match="@*" mode="copy">
  70.       <xsl:param name="pContents"/>
  71.       
  72.       <xsl:attribute name="{name()}">
  73.         <xsl:copy-of select="$pContents"/>
  74.       </xsl:attribute>
  75.     </xsl:template>
  76.  
  77. </xsl:stylesheet>